package charstream;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("Day13\\a.txt");
        //method1(fr);
        //一次读多个字符
        //把读到的字符都存入到chars数组；返回值：表示本次读到了多少个字符
        char [] chars =new char[1024];
        int len;
        while ((len = fr.read(chars))!=-1){
            System.out.println(new String(chars,0,len));
        }
        fr.close();
    }
    private static void method1(FileReader fr) throws IOException {
        //一次读一个字符
        int ch;
        while ((ch= fr.read())!=-1){
            System.out.print((char)ch);
        }
        fr.close();
    }
}
